home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 001-010 / amok06 / iffsupport / demos / iffbitmapdemo.mod < prev    next >
Text File  |  1993-11-04  |  3KB  |  106 lines

  1. (*---------------------------------------------------------------------------
  2.     :Program.    IFFBitMapDemo.mod
  3.     :Author.     Fridtjof Siebert
  4.     :Address.    Nobileweg 67, D-7-Stgt-40
  5.     :Phone.      0711/822509
  6.     :Shortcut.   [fbs]
  7.     :Version.    1.0
  8.     :Date.       20.04.88
  9.     :Copyright.  PD
  10.     :Language.   Modula-II
  11.     :Translator. M2Amiga
  12.     :Imports.    IFFSupport [fbs].
  13.     :UpDate.     none.
  14.     :Contents.   Demo für dontopen-Option von ReadILBM().
  15.     :Remark.     Let's wave !!!
  16. ---------------------------------------------------------------------------*)
  17. MODULE IFFBitMapDemo;
  18.  
  19. FROM SYSTEM     IMPORT ADR, ADDRESS, SHIFT, BITSET, LONGSET, CAST;
  20.  
  21. FROM Arguments  IMPORT NumArgs, GetArg;
  22.  
  23. FROM Intuition  IMPORT ScreenPtr, CloseScreen, DisplayBeep, WindowPtr,
  24.                        OpenScreen;
  25. FROM Graphics   IMPORT BitMap, BitMapPtr;
  26. FROM Exec       IMPORT FreeMem;
  27.  
  28. FROM IFFSupport IMPORT ReadILBM, ReadILBMFlags, ReadILBMFlagSet, NuScreen,
  29.                        IFFInfo, IFFInfoType;
  30.  
  31. VAR
  32.   MyScreen: ScreenPtr;        (* the Picture's Screen *)
  33.   WindowDummy: WindowPtr;     (* a Dummy WindowPointer *)
  34.   Name: ARRAY[0..79] OF CHAR; (* the Pic's Name *)
  35.   length: INTEGER;            (* the Name's length (not used) *)
  36.   Ciapra [0BFE001H]: SET OF (s0,s1,s2,s3,s4,s5,lmb); (* left Button *)
  37.   MyBitMap: BitMapPtr;        (* for saving BitMapAddress *)
  38.   MyIFFInfo: IFFInfoType;     (* for saving IFFInfo *)
  39.   PlaneSize: LONGINT;         (* Size of one BitPlane *)
  40.   i: CARDINAL;                (* Counts BitPlanes *)
  41.  
  42. BEGIN
  43.  
  44. (*------  Get Name:  ------*)
  45.  
  46.   IF NumArgs()#0 THEN
  47.     GetArg(1,Name,length);
  48.   ELSE
  49.     HALT;
  50.   END;
  51.  
  52. (*------  Read ILBM:  ------*)
  53.  
  54.   IF ReadILBM(Name,ReadILBMFlagSet{front,visible,dontopen},MyScreen,
  55.               WindowDummy) THEN
  56.  
  57.     (*------  Save important Data:  ------*)
  58.  
  59.     MyIFFInfo := IFFInfo;
  60.     MyBitMap := NuScreen.customBitMap;
  61.     (* this needn't be done in this program, but has to, as soon as there  *)
  62.     (* are more than one Pictures loaded. So it's done in this Example     *)
  63.  
  64.     (*------  Open Screen:  ------*)
  65.  
  66.     MyScreen := OpenScreen(NuScreen);
  67.  
  68.     (*------  Wait for left Button:  ------*)
  69.  
  70.     WHILE lmb IN Ciapra DO END;
  71.  
  72.     (*------  Close Screen:  ------*)
  73.  
  74.     CloseScreen(MyScreen);
  75.  
  76.     (*------  Free BitMap's Memory:  ------*)
  77.  
  78.     (* calculate Size of BitPlane: *)
  79.     WITH MyIFFInfo.BMHD DO
  80.       IF scrnWidth>width THEN
  81.       (* If Image is greater than Screen, a bigger BitMap is allocated ! *)
  82.         PlaneSize := scrnWidth;
  83.       ELSE
  84.         PlaneSize := width;
  85.       END;
  86.       IF scrnHeight>height THEN
  87.         PlaneSize := PlaneSize DIV 8 * scrnHeight;
  88.       ELSE
  89.         PlaneSize := PlaneSize DIV 8 * height;
  90.       END;
  91.     END;
  92.     WITH MyBitMap^ DO
  93.       FOR i:=0 TO depth-1 DO
  94.         FreeMem(planes[i],PlaneSize); (* Free Memory of each Plane *)
  95.       END;
  96.     END;
  97.     FreeMem(MyBitMap,SIZE(BitMap)); (* Free Memory of BitMap-Structure *)
  98.  
  99.   ELSE (* any Error occured while loading Picture: *)
  100.  
  101.     DisplayBeep(NIL); (* Let's display a Beep ! *)
  102.  
  103.   END;
  104.  
  105. END IFFBitMapDemo. Never forget to free BitMap's Memory !!!
  106.